<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>Title</title>
    
    <style>
      .box {
        display: grid;
        /* 最小宽度为300px，宽度小于300px时列数自适应且列宽度为1fr */
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
        gap: 20px;
      }
      
      .card {
        background: pink;
        height: 100px;
      }
    </style>
  </head>
  <body>
    <div class="box">
      <div class="card"></div>
      <div class="card"></div>
      <div class="card"></div>
      <div class="card"></div>
      <div class="card"></div>
      <div class="card"></div>
      <div class="card"></div>
    </div>
  </body>
</html>